class BaseModel {
    constructor(data, message, code) {
        if (typeof data === 'string') {
            this.message = data
            data = null
            message = null
        }
        if (data) {
            this.data = data
        }
        if (message) {
            this.message = message
        }
        if (code) {
            this.code = code
        }
    }
}

class SuccessModel extends BaseModel {  // 用于全局调用返回确认信息
    constructor(data, message = '', code=200) {
        super(data, message, code)
    }
}

class ErrorModel extends BaseModel {  // 用于全局调用返回错误信息
    constructor(data={}, message = '', code=-1) {
        super(data, message, code)
    }
}

module.exports = {
    SuccessModel,
    ErrorModel
}
